package com.nathan.crm.config;

import com.nathan.crm.interceptor.NoLoginInterceptor;
import com.nathan.crm.reslover.MyLocalReslover;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer {

    @Bean
    public NoLoginInterceptor getNoLoginInterceptor(){
        return new NoLoginInterceptor();
    }

    /**
     * 添加拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getNoLoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/css/**","/images/**","/js/**","/lib/**","/index","/user/login");
    }

    @Bean
    public LocaleResolver localeResolver(){
        return new MyLocalReslover();
    }
}
